package GUI;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;

import Controller.ParkingLotWorkerController;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;

/**
 * this is the GUI for the parking lot worker.
 * he can do those options: car checkout, initialize parking spot and disable/activate/save parking spot.
 * @author Or Marx
 *
 */
public class ParkingLotWorkerGui extends JPanel{
	private JFrame frame;
	private JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	public void setFrame (JFrame frame)
	{
		this.frame=frame;}
	/**
	 * is the constructor of the GUI. it has 3 action listerns.
	 * 1. car check out, which will be called by the parking lot worker controller.
	 * 2. initialize parking spot, which will be called by the parking lot worker controller.
	 * 3. save/disable/activate parking spot, which will be called by the parking lot worker controller.
	 */
	public ParkingLotWorkerGui() {	
		setLayout(null);
		JButton btnCheckout = new JButton("car checkout");
		btnCheckout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ParkingLotWorkerController plw=new ParkingLotWorkerController();
				plw.carCheckout();
			}
		});
		btnCheckout.setBounds(389, 162, 150, 23);
		add(btnCheckout);
		
		JButton btnInitializeParkingSpot = new JButton("initialize Parking Spot");
		btnInitializeParkingSpot.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ParkingLotWorkerController plw=new ParkingLotWorkerController();
				plw.initParkingLot();
			}
		});
		btnInitializeParkingSpot.setBounds(352, 110, 211, 23);
		add(btnInitializeParkingSpot);
		
		JButton btnDisablesaveParkingSpot = new JButton("disable/save/activate Parking Spot");
		btnDisablesaveParkingSpot.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg1) {
				ParkingLotWorkerController plw=new ParkingLotWorkerController();
				plw.disableSaveActivatePspot();
			}
		});
		btnDisablesaveParkingSpot.setBounds(368, 223, 205, 23);
		add(btnDisablesaveParkingSpot);
		
		JButton btnCancel = new JButton("logout");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(lastPanel);
			}
		});
		btnCancel.setBounds(422, 318, 89, 23);
		add(btnCancel);
		
		JLabel lblHiParkingLot = new JLabel("Hi!, parking lot worker");
		lblHiParkingLot.setFont(new Font("Tahoma", Font.PLAIN, 29));
		lblHiParkingLot.setBounds(312, 11, 383, 88);
		add(lblHiParkingLot);
	}
}